package net.dreamlu.system.web;

import lombok.AllArgsConstructor;
import net.dreamlu.common.base.BaseController;
import net.dreamlu.common.result.EasyPage;
import net.dreamlu.common.result.PageVO;
import net.dreamlu.system.model.VlogCensor;
import net.dreamlu.system.model.VlogEffects;

import net.dreamlu.system.service.IVlogEffectsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
@RequestMapping("/vlogEffects")
@AllArgsConstructor
public class VlogEffectsController extends BaseController {

	@Autowired
	private IVlogEffectsService vlogEffectsService;

	@GetMapping("/manager")
	public String manager() {
		return "system/vlogEffects/vlogEffectsList";
	}

	@PostMapping("/dataGrid")
	@ResponseBody
	public EasyPage<VlogEffects> dataGrid(VlogEffects vlogEffects, PageVO pageVO) {
		// 分页查询
		EasyPage<VlogEffects> easyPage = vlogEffectsService.selectPage(vlogEffects, pageVO);
		return easyPage;
	}

	//添加
//	@PostMapping("add")
//	@ResponseBody
//	public Object add(VlogCensor vlogEffects){
//
//		Date date = new Date();
//		vlogEffects.setCreateTime(date);
//		vlogEffects.setUpdateTime(date);
//
//		Byte b = 0;
//		vlogEffects.setStatus(b);
//		vlogEffects.setAuditor("admin");
//		boolean save = vlogEffectsService.save(vlogEffects);
//		return status(save);
//	}

	/**
	 * 编辑的page
	 * @param id
	 * @param model
	 * @return
	 */
/*	@RequestMapping("editPage")
	public String editPage(Integer id, Model model){
		VlogCensor byId = vlogEffectsService.getById(id);
		model.addAttribute("vlogEffects",byId);
		//跳转到编辑的html
		return "system/vlogEffects/vlogEffectsEdit";
	}
	@PostMapping("edit")
	@ResponseBody
	public Object edit(VlogCensor vlogEffects){

		Date date = new Date();
		vlogEffects.setUpdateTime(date);

		boolean update = vlogEffectsService.updateById(vlogEffects);
		return status(update);
	}


	@PostMapping("delete")
	@ResponseBody
	public Object delete(Integer id){

		boolean delete = vlogEffectsService.removeById(id);
		return status(delete);
	}*/

}
